import { lazy } from 'react'
import AuthRoute from '@/components/auth'

// 懒加载语法：const 组件名 = lazy(() => import('组件路径'))
const Layout = lazy(() => import('@/pages/layout'))
const Login = lazy(() => import('@/pages/login'))
const NotFound = lazy(() => import('@/pages/404'))
const Test = lazy(() => import('@/pages/test'))
// 子路由懒加载
const Home = lazy(() => import('@/pages/home'))
const Article = lazy(() => import('@/pages/article'))
const Publish = lazy(() => import('@/pages/publish'))

// v6
export const routes = [
  {
    path: '/',
    // element: <Layout />,
    element: <AuthRoute element={<Layout />} />,
    children: [
      { path: '/', element: <Home /> },
      { path: '/article', element: <Article /> },
      { path: '/publish/*', element: <Publish /> },
    ],
  },
  {
    path: '/login',
    element: <Login />,
  },
  {
    path: '/test',
    element: <Test />,
  },
  {
    path: '*',
    element: <NotFound />,
  },
]